﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibFriesland_Campina_CRM;

public partial class Popup_SupAction : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["account"] == null)
            Response.Redirect("../login.aspx");
        if (!IsPostBack)
        {
            databindSupAction();
        }
    }

    //Lien ket du lieu
    protected void databindSupAction()
    {
        string by_na = Request.QueryString["by_na"].ToString();
        string by_shop = Request.QueryString["by_shop"].ToString();
        string by_shift = Request.QueryString["by_shift"].ToString();
        string byDatetimeStr = Request.QueryString["byDatetime"].ToString();
        DateTime byDatetime = Convert.ToDateTime(Thuvien.myConvertStringToShortDate(byDatetimeStr));
        string byTime_point = Request.QueryString["byTime_point"].ToString();
        List<BizAttendanceTracking> atdList = BizAttendanceTracking.getFullAttendanceTrackingbyNA(by_na, byDatetime, by_shop, by_shift);

        atdList = atdList.FindAll(
                                delegate(BizAttendanceTracking atd)
                                {
                                    if (atd.by_time_point == byTime_point)
                                        return true;
                                    else
                                        return false;
                                });

        atdList = atdList.FindAll(
                                delegate(BizAttendanceTracking atd)
                                {
                                    if (atd.action_monitoring.Trim() != "" || atd.comment_monitoring != "")
                                        return true;
                                    else
                                        return false;
                                });

        grvSupAction.DataSource = atdList;
        grvSupAction.DataBind();
        if (atdList.Count == 0)
            pldInfo.Visible = true;
        else
            pldInfo.Visible = false;
    }
}